<?php
if (!defined("_INDEX")) { header("Location: /"); die; }

$users = $db->getTable("select `user_id`,`login`,`last_time` from `users` order by `user_id`");

$online = array();
$now = time();
foreach ($users as $u)
	if ($u['last_time'] > $now - TIME_ONLINE)
		$online[] = $u;


require_once ADMIN.DS."head.php";
?>
<script type="text/javascript">
$(document).ready(function(){
	var show_all_users = false;
	$("#show_all_users").click(function(){
		if (!show_all_users){
			$(this).addClass("active");
			$("#all_users_list").slideDown(200);
		} else {
			$(this).removeClass("active");
			$("#all_users_list").slideUp(200);
		}
		show_all_users = !show_all_users;
	})
	var show_online_users = false;
	$("#show_online_users").click(function(){
		if (!show_online_users){
			$(this).addClass("active");
			$("#online_users_list").slideDown(200);
		} else {
			$(this).removeClass("active");
			$("#online_users_list").slideUp(200);
		}
		show_online_users = !show_online_users;
	})
})
</script>
<div class="full">
	<div class='submenu_container'>
		<a class="submenu_button submenu_button_active" href="/admin/users/short">Коротко</a>
		<a class="submenu_button" href="/admin/users/full">Полностью</a>
	</div>
	
	<h3>Пользователи</h3>
	<div class='text-container'>
		<p>Всего зарегистрировано: <?php echo count($users); ?></p>
		<div class='more'>
			<div class='group_container'>
				<a class="group wimg" id="show_all_users" href='javascript:void(0)'>Показать всех</a>
			</div>
			<div class='list_container' id='all_users_list'><?php
				foreach ($users as $key => $u)
				{
					echo "<a href='/admin/users/full/#user_$u[user_id]'>$u[login]</a>";
					if ($key < count($users) - 1)
						echo ", ";
				}
			?></div>
		</div>
		<p>Сейчас онлайн: <?php echo count($online); ?></p>
		<div class='more'>
			<div class='group_container'>
				<a class="group wimg" id="show_online_users" href='javascript:void(0)'>Показать всех</a>
			</div>
			<div class='list_container' id='online_users_list'><?php
				foreach ($online as $key => $u)
				{
					echo "<a href='/admin/users/full/#user_$u[user_id]'>$u[login]</a>";
					if ($key < count($online) - 1)
						echo ", ";
				}
			?></div>
		</div>
	</div>
</div>
<?php require_once ADMIN.DS."footer.php"; ?>
